import java.util.Arrays;

public class Test2 {

    //调整数组顺序使得奇数位于偶数之前。调整之后，不关心大小顺序。
    //如数组：[1,2,3,4,5,6]
    //调整后可能是：[1, 5, 3, 4, 2, 6]

    public static int[] tranArr(int[] arr) {
        int len = arr.length;

        int[] newArr = new int[len];

        int count1 = 0;
        int count2 = len - 1;

        for (int i = 0; i < len; i++) {
            if (arr[i] % 2 == 1) {//奇数
                newArr[count1] = arr[i];
                count1++;
            } else {//偶数
                newArr[count2] = arr[i];
                count2--;
            }
        }

        return newArr;
    }

    public static void main(String[] args) {
        int[] arr = new int[]{1,2,3,4,5,6};

        System.out.println(Arrays.toString(arr));

        int[] retArr = tranArr(arr);

        System.out.println(Arrays.toString(retArr));
    }
}
